#include "CAppStateCredits.h"

#include "CAppStateManager.h"

CAppStateCredits CAppStateCredits::Instance;

CAppStateCredits::CAppStateCredits() {
    Surf_Logo = NULL;
}

void CAppStateCredits::OnActivate() {
    // Load Simple Logo
    Surf_Logo = CSurface::OnLoad("content/image/credits.jpg");
    Font = CFont::OnLoad("content/fonts/visitor2.ttf", 25);

    StartTime = SDL_GetTicks();
}

void CAppStateCredits::OnDeactivate() {
    SDL_FreeSurface(Surf_Logo);
    Surf_Logo = NULL;
}

void CAppStateCredits::OnLoop() {
    if(StartTime + 100 < SDL_GetTicks()) {
        CAppStateManager::SetActiveAppState(APPSTATE_NONE);
    }
}

void CAppStateCredits::OnRender(SDL_Surface* Surf_Display) {
    if(Surf_Logo) {
        CSurface::OnDraw(Surf_Display, Surf_Logo, 0, 0);
    }
    CFont::OnDraw(Font, 0, "v1.0_Beta", Surf_Display, 540, 458);
}

CAppStateCredits* CAppStateCredits::GetInstance() {
    return &Instance;
}
